package com.gaussian.property.admin.module.biz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gaussian.property.admin.module.biz.service.ProjectReportService;
import com.gaussian.property.module.biz.vo.projectreport.AddProjectReport;
import com.gaussian.property.module.biz.vo.projectreport.PageQueryProjectReportRequest;
import com.gaussian.property.module.biz.vo.projectreport.ProjectReportFileVO;
import com.gaussian.property.module.quartz.task.BizTask;
import com.songqi.common.core.domain.R;
import com.songqi.common.core.domain.page.PageDataInfo;
import com.songqi.common.web.request.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description:
 * @author: songqi(13776346982)
 * @date: 2024/8/11 12:14
 */
@Api(tags = "项目报告上传、删除")
@Validated
@RestController
@RequestMapping("projectReport/")
public class ProjectReportController extends BaseController {
    @Resource
    private ProjectReportService projectReportService;
    @Resource
    private BizTask bizTask;



    @ApiOperation("分页查询项目报告")
    @GetMapping("pageQueryProjectReport")
    public R<PageDataInfo<ProjectReportFileVO>> pageQueryProjectReport(PageQueryProjectReportRequest queryRequest) {
        IPage<ProjectReportFileVO> pageData = projectReportService.pageQueryProjectReport(queryRequest);
        return getReturnDataTableInfo(pageData);
    }

    @ApiOperation("上传项目报告")
    @PostMapping("addProjectReport")
    public R<Void> addProjectReport(@RequestBody @Validated AddProjectReport addProjectReport){
        projectReportService.addProjectReport(addProjectReport);
        return success();
    }


    @ApiOperation("更改项目报告删除状态。返回更新后的状态。1-刪除，0-正常")
    @PostMapping("changeStatus/{projectReportFileId}")
    public R<Integer> changeStatus(@PathVariable String projectReportFileId){
        return success(projectReportService.changeStatus(projectReportFileId));
    }


    @ApiOperation("测试用，不能被前端调用")
    @GetMapping("testCreateCheckReport")
    public R<Void> testCreateCheckReport(String yearMonth){
        bizTask.createMonthlyCheckReport(yearMonth);
        return success();
    }

}
